<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			function fun(){
				//1.创建 XMLHttpRequest 对象
				let xhr = new XMLHttpRequest()
				//2.创建请求
				xhr.open("GET","data.txt",false) //false表示同步请求
				//3.发送请求
				xhr.send()
				//4.接收，解析，显示数据
				let data = xhr.responseText
				document.querySelector("span").innerHTML = data
				
			}
		</script>
	</head>
	<body>
		请求到的数据是：<span></span><br>
		<button type="button" onclick="fun()">请求</button>
		
	</body>
</html>
